<?php

// Copyright 2019 Hackware SpA <human@hackware.cl>
// "Hackware Web Services Core" is released under the MIT License terms.

namespace Hawese\Tests;

// use PHPUnit\Framework\TestCase as BaseTestCase; // Eventually
use Laravel\Lumen\Testing\TestCase as BaseTestCase;

abstract class TestCase extends BaseTestCase
{
    public function createApplication()
    {
        return require 'bootstrap/app.php';
    }

    /**
     * Access to database schema builder without Schema facade
     */
    protected static function schema()
    {
        return app('db')->connection()->getSchemaBuilder();
    }

    /**
     * I don't want it fluent.
     */
    public function request(
        $method,
        $uri,
        array $data = [],
        array $headers = []
    ) {
        $this->json($method, $uri, $data, $headers);
        return $this->response;
    }

    protected function validOrigin()
    {
        return preg_split('/, ?/', env('CORS_ALLOW_ORIGINS'))[0];
    }
}
